﻿' ----------------------------------------------------------------------------------
' Microsoft Developer & Platform Evangelism
' 
' Copyright (c) Microsoft Corporation. All rights reserved.
' 
' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ----------------------------------------------------------------------------------
' The example companies, organizations, products, domain names,
' e-mail addresses, logos, people, places, and events depicted
' herein are fictitious.  No association with any real company,
' organization, product, domain name, email address, logo, person,
' places, or events is intended or should be inferred.
' ----------------------------------------------------------------------------------

Namespace ViewModel

    Public MustInherit Class PivotItemViewModel
        Inherits BaseViewModel
        Public Sub UpdateApplicationBarButtons(ByVal applicationBar As IApplicationBar, ByVal preserveButtons() As String)
            ' Create a list of the buttons to preserve in the application bar.
            Dim preserveButtonsList = New List(Of IApplicationBarIconButton)()
            For Each button As IApplicationBarIconButton In applicationBar.Buttons
                If preserveButtons.Contains(button.Text) Then
                    preserveButtonsList.Add(button)
                End If
            Next button

            ' Clear the current buttons in the application bar.
            applicationBar.Buttons.Clear()

            ' Add application bar buttons specific of the pivot item.
            Me.PopulateApplicationBarButtons(applicationBar)

            ' Add the preserved application bar buttons.
            For Each button In preserveButtonsList
                applicationBar.Buttons.Add(button)
            Next button
        End Sub

        Protected MustOverride Sub PopulateApplicationBarButtons(ByVal applicationBar As IApplicationBar)
    End Class
End Namespace